import count from '@dfeidao/atom-nodejs/db/count';
import query from '@dfeidao/atom-nodejs/db/query';
import { IncomingHttpHeaders } from 'http';
import { productid,systemid } from '../../atom/config';
interface Message {
	pn: number;
	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}

// interface IWebResult {
// 	data: unknown;
// 	cookie?: {
// 		[name: string]: string;
// 	} | null;
// 	content_type?: string;
// 	headers?: {
// 		[key: string]: string[];
// 	};
// 	attachment?: string;
// 	redirect?: string;
// 	status_code?: number;
// }

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	const p = query(action_id, session_id, systemid);
	p.prepare('risk_management', ['risk_no', 'risk_content','risk_type','project_no','project_name','create_time','risk_status'], { productid}, 20,message.pn, [], ['create_time']);
	const [dt] = await p.exec();
	const { prepare, exec } = count(action_id, session_id, systemid);
	prepare('risk_management', { productid });
	const [c] = await exec();
	return{dt,c};
}
